package com.fu.plugin.actions;

import com.fu.plugin.navigation.MyNavigationItem;
import com.intellij.navigation.ChooseByNameContributor;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class MyChooseByname implements ChooseByNameContributor {

    public static List<MyNavigationItem> list = new ArrayList<>();

    public MyChooseByname(){
        for(int i = 0; i < 20; i++){
            list.add(new MyNavigationItem(i + "", null));
        }
    }

    @NotNull
    @Override
    public String[] getNames(Project project, boolean b) {
        return list.parallelStream().map(MyNavigationItem::getValue).toArray(String[]::new);
    }

    @NotNull
    @Override
    public NavigationItem[] getItemsByName(String s, String s1, Project project, boolean b) {
        NavigationItem[] navigationItems = list.parallelStream().filter(p->p.getValue().equals(s)).toArray(NavigationItem[]::new);
        return navigationItems;
    }
}
